package controller

import (
	"publiclib/stateless"
)

type CommonAppStdResp struct {
	Code    int         `json:"error_code"`
	Message string      `json:"error_msg"`
	Data    interface{} `json:"data"`
}

func genNormalAppResponseToJson(data interface{}, msg string) *CommonAppStdResp {
	if data == nil {
		data = struct{}{}
	}
	return &CommonAppStdResp{
		Code:    stateless.Success,
		Message: msg,
		Data:    data,
	}
}

func genNormalAppErrorResp(code int, msg string) *CommonAppStdResp {
	return &CommonAppStdResp{
		Data:    struct{}{},
		Code:    code,
		Message: msg,
	}
}

func genNormalAppErrorWithDataResp(data interface{}, code int, msg string) *CommonAppStdResp {
	return &CommonAppStdResp{
		Data:    data,
		Code:    code,
		Message: msg,
	}
}

func genNormalAppErrorRespWithData(data interface{}, code int, msg string) *CommonAppStdResp {
	return &CommonAppStdResp{
		Code:    code,
		Message: msg,
		Data:    data,
	}
}
